Repository navigation
Conversation
|
Can one of the admins verify this patch?
|
| { | ||
| #ifdef __ZEPHYR__ | ||
| int32_t bit = ffs(flag) - 1; | ||
| atomic_val_t mask = (atomic_val_t)flag; |
There was a problem hiding this comment.
@checkupup sorry not following the commit message here, not following what is being treated as an array by the compiler ?
There was a problem hiding this comment.
atomic_*_bit functions use ATOMIC_ELEM macro to retrieve element:
// include/zephyr/sys/atomic.h
#define ATOMIC_BITS (sizeof(atomic_val_t) * BITS_PER_BYTE)
#define ATOMIC_MASK(bit) BIT((unsigned long)(bit) & (ATOMIC_BITS - 1U))
#define ATOMIC_ELEM(addr, bit) ((addr) + ((bit) / ATOMIC_BITS))
static inline bool atomic_test_and_clear_bit(atomic_t *target, int bit)
{
atomic_val_t mask = ATOMIC_MASK(bit);
atomic_val_t old;
old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);
return (old & mask) != 0;
}It treats target pointer as an array pointer. In dax.c, if bit > sizeof(uint32_t), it may return &proc_flags + 1 address , resulting in out-of-bounds access.
I will update a commit message to describe the issue more clearly
Out-of-bounds access (ARRAY_VS_SINGLETON): atomic_*_bit functions use ATOMIC_ELEM macro to retrieve element, which treats target pointer as an array pointer. In dax.c, if bit > sizeof(uint32_t), it may return an &proc_flags + 1 address , resulting in out-of-bounds access. Signed-off-by: Jun Lai <junlai@dolby.com>
9c2c496 to
20d278d
Compare
PR 11454: test resultsRun date: 2026-11-16 13:57 UTC Tested commit: 20d278db673751045112ac6023d09cd06c4a853f |
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the Dolby DAX atomic-flag update.
No open issues 🎉
What changed in this PR
Addresses Coverity’s ARRAY_VS_SINGLETON warning in the Dolby DAX adapter by replacing bit-indexed atomic operations with word-level operations on the single proc_flags value.
Changes:
- Uses an explicit mask for Zephyr flag reads, sets, and clears.
- Preserves unrelated flags and returns the previous flag state for read-and-clear operations.
| File | Description |
|---|---|
src/audio/module_adapter/module/dolby/dax.c |
Replaces Zephyr bit-indexed atomic calls with masked word-level operations. |
Review effort: Balanced
Out-of-bounds access (ARRAY_VS_SINGLETON): original calls may treat proc_flags as an array.